<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <script>
        //定义一个圆类 有半径、面积、周长等属性，还有计算面积、周长的方法
        class Circle {
            static pi = 3.14;
            constructor(radius) {
                this.radius = radius;
                this.area = -1;
                this.length = -1;
            }
            getArea() {
                // Circle.area = Circle.pi * Circle.radius * Circle.radius
                return Circle.pi * this.radius ** 2
                // console.log('面积是' + area)
            }
            getLength() {
                console.log('周长是' + 2 * pi * radius / 2)
            }
        }
        var a = new Circle(2);
        // a.area();
    </script>
</body>

</html>